#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>

int main()
{
    pid_t pid = fork();
    if (pid == 0)
    {
        // 子进程
        printf("I am a child process\n");
        sleep(5);
        return 10;
    }
    // 父进程
    else
    {
        int status;
        int rid = waitpid(pid, &status, 0);
        if (rid >0)
        {
            printf("退出码为%d,退出信号为%d\n", (status >> 8) & 0xFF, status & 0x7F);
        }
    }

    return 0;
}